<template>
  <div class="smart-home-viewer">
    <!-- 智能家居iframe显示区域 -->
    <div class="model-viewer">
      <iframe 
        src="http://127.0.0.1:11191/video.html" 
        class="video-iframe"
        frameborder="0"
        allowfullscreen
      ></iframe>
    </div>
    
    <!-- 加载状态 -->
    <div class="loading-overlay" v-if="loading">
      <div class="loading-content">
        <a-spin size="large" />
        <div class="loading-text">{{ loadingText }}</div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'

// 响应式状态
const loading = ref(true)
const loadingText = ref('正在加载智能家居场景...')

// 初始化
const init = async () => {
  loadingText.value = '正在加载智能家居场景...'
  
  // 模拟加载时间
  setTimeout(() => {
    loading.value = false
  }, 1000)
}

// 生命周期
onMounted(() => {
  init()
})
</script>

<style scoped>
.smart-home-viewer {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* 智能家居iframe显示区域 - 参考Dashboard.vue的样式 */
.model-viewer {
  flex-grow: 1;
  /* background-color: #000; */
  /* border-radius: 8px; */
  position: relative;
  width: 100%;
  height: 100%;
  transform: scale(0.7, 0.7);
  transform-origin: top left;
  max-height: 70vh;
}

.video-iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 150%;
  height: 150%;
  border: none;
  border-radius: 8px;
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(79, 172, 254, 0.2);
  min-width: 300px;
}

.loading-text {
  color: #333;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

/* 响应式设计 - 参考Dashboard.vue的响应式设计 */
@media (max-width: 1200px) {
  .model-viewer {
    max-height: 65vh;
  }
}

@media (max-width: 768px) {
  .model-viewer {
    max-height: 50vh;
    aspect-ratio: 16 / 9;
  }
  
  .loading-content {
    padding: 24px;
    min-width: 280px;
    margin: 20px;
  }
}

/* 动画效果 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.model-viewer {
  animation: fadeIn 0.5s ease-out;
}
</style>
  




